<!doctype html>
<!--复制自cb的login,重命名啊，测试完删除-->
<html  class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/xadmin.js"></script>
    <script type="text/javascript" src="js/cookie.js"></script>

</head>
<body class="login-bg">
<div class="login layui-anim layui-anim-up">
    <div class="message">登录</div>
    <div id="darkbannerwrap"></div>

    <form method="post" class="layui-form">
        <input name="UName" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" id="UName" >
        <hr class="hr15">
        <input name="Pwd" lay-verify="required" placeholder="密码"  type="password" class="layui-input" id="Pwd">
        <hr class="hr15">
        <select name="Type" id="Type"class="layui-inline">
            <option value="用户">用户</option>
            <option value="商家">商家</option>
            <option value="快递员">快递员</option>
            <option value="管理员">管理员</option>
        </select>
        <hr class="hr15">
        <input onclick="Commit()" value="登录" lay-submit lay-filter="login" style="width:100%;" type="button" >
        <hr class="hr20" >
    </form>
</div>

<script>
    function Commit(){//提交数据
        var layedit = layui.layedit;
        $.ajax({
            url:'http://localhost:8081/Login/DoLogin',//请求地址
            method:'GET',//请求的方法
            dataType:'JSON',//值类型
            data:{
                UName:$("#UName").val(),
                Pwd:$("#Pwd").val(),
                Type:$("#Type").val()
            },//往后端发送的值
            success:function(res){//成功的回调函数
                if(res.code==="0" && $("#Type").val() == "用户"){
                    localStorage.setItem("UName",$("#UName").val());
                    console.log("11111")
                    location.href="index-user.html"
                }else{
                    alert("账号或密码或类型错误")
                }
            },
            error:function (data) {//失败的回调函数
                alert("系统出错");
            }
        })
    }
</script>
</body>
</html>
